home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Day Cry
/
Day Cry CD.bin
/
oh_towns
/
taropyon
/
splib
/
splib.lzh
/
PRG
/
LHX
/
ERROR.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-08
|
2KB
|
96 lines
/***********************************************************
error.c -- error processing
***********************************************************/
#include "lh386.h"
#include <fslib.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "lh.h"
#include "errmes.h"
#ifdef __HIGHC__
# pragma On(Align_labels);
#endif
/* :*****************************************************************
: process for error
:*****************************************************************
*/
void error(char *errmes, char *p)
{
if ( errmes == COPYERR )
{ /* error during copying temporary? */
LHX_printf( "\n%s\n", COPYERR );
FS_fclose( file1 );
FS_remove(arcname); /* erase incomplete archive */
file1 = NULL;
} else
LHX_printf( "\n%s", errmes);
if ( p )
{
LHX_printf( " : '%s'", p );
}
LHX_puts( "\n");
if (file3 != NULL)
{
FS_fclose(file3);
if (cmd == 'E') /* during extracting */
FS_remove(filename3); /* delete the file */
}
if (file1 != NULL)
{
FS_fclose(file1);
if (cmdupdate) /* during updating */
FS_rename(filename1, arcname); /* recover old archive */
}
if (file2 != NULL)
{
FS_fclose(file2);
if (errmes != COPYERR)
{ /* if not copying */
FS_remove(filename2); /* delete temporary */
}
}
END_EXIT:
if (errmes == COPYERR)
MAIN_EXIT(3);
else
MAIN_EXIT(2);
}
void fileerror(char *err, FILE * file)
{
char *name;
name = NULL;
if (file == file1)
name = filename1;
if (file == file2)
name = filename2;
if (file == file3)
name = hpb.pathname;
error(err, name);
}
/*******************************
handle user break
*******************************/
void userbreak(int code)
{
code = code;
error(CTRLBRK, NULL);
}
void initbreak(void)
{
#ifndef __HIGHC__
signal(SIGINT, userbreak);
#endif
}